<template>
    <div>
        <h1>显示</h1>
        商铺名称<input type="text" v-model="info.names">
        商铺状态<select v-model="info.ztid">
            <option value="">请选择</option>
            <option :value="itme.Id" v-for="itme in lisr" :key="itme.Id">{{ itme.ShopName }}</option>
        </select>
        <input type="button" value="查询" @click="getlist()">
        <input type="button" value="重置" @click="rate()">
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>商铺名称</td>
                    <td>商铺楼层</td>
                    <td>商铺编号</td>
                    <td>建筑面积</td>
                    <td>租金</td>
                    <td>手机号</td>
                    <td>商铺状态</td>
                    <td>时间</td>
                    <td>操作</td>
                </tr>

                <tr v-for="itme in data.list" :key="itme.Id">
                    <td>{{ itme.Name }}</td>
                    <td>{{ itme.ShopLX }}</td>
                    <td>{{ itme.ShopBH }}</td>
                    <td>{{ itme.ShopMJ }}</td>
                    <td>{{ itme.Money }}</td>
                    <td>{{ itme.Tel.substring(0, 3) + '****' + itme.Tel.substring(7) }}</td>
                    <td>{{ itme.ShopName }}</td>
                    <td>{{ moment(itme.DateTime).format("YYYY-MM-DD hh:mm:ss") }}</td>
                    <td><input type="button" value="删除" @click="del(itme.Id)">
                        <input type="button" value="修改" @click="xg(itme.Id)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
import moment from 'moment';
const router = useRouter()
const route = useRoute()
let info: any = reactive({
    names: '',
    ztid: ''
})
let data: any = reactive({
    list: []
})
let lisr: any = ref([]);
onMounted(() => {
    getlist();
    getlisr()
})

//==============================下拉框
const getlisr = () => {
    axios({
        url: '/api/FX/GetShou',
        method: 'get'

    })
        .then((res) => {
            console.log(res);
            lisr.value = res.data

        })
        .catch((err) => {
            console.log(err);

        })
}
//===============================显示
const getlist = () => {
    axios({
        url: '/api/FX/GetShow',
        method: 'get',
        params: info
    })
        .then((res) => {
            console.log(res);
            data.list = res.data;

        })
        .catch((err) => {
            console.log(err);

        })
}
//===============================重置
const rate = () => {
    info.names = '',
        info.ztid = ''
}
//===============================删除
const del = (id: any) => {
    let f = confirm('确认删除吗？')
    if (f) {
        axios({
            url: '/api/FX/Del',
            method: 'delete',
            params: { id: id }

        })
            .then((res) => {
                console.log(res);
                if (res.data > 0) {
                    alert('删除成功')
                    getlist();
                    return;
                }
                else {
                    alert('删除失败')
                    return;
                }

            })
            .catch((err) => {
                console.log(err);

            })
    }

}
//===============================修改
const xg = (id: any) => {
    router.push({
        path: '/xg',
        query: { id: id }
    })
}
</script>

<style scoped></style>